<template>
    <div>
        <van-nav-bar
  title="标题"
  left-text="返回"
  left-arrow
  @click-left="onClickLeft"
/>
<!-- 优惠券单元格 -->
<van-coupon-cell
  :coupons="coupons"
  :chosen-coupon="chosenCoupon"
  @click="showList = true"
/>
<!-- 优惠券列表 -->
<van-popup
  v-model:show="showList"
  round
  position="bottom"
  style="height: 90%; padding-top: 4px;"

>
  <van-coupon-list
    :coupons="coupons"
    :chosen-coupon="chosenCoupon"
    @change="onChange"
    @exchange="onExchange"
  />

</van-popup>
    </div>
</template>

<script setup lang="ts">

import {ref} from 'vue'

const coupon:any = {
      available: 1,
      condition: '无门槛\n最多优惠12元',
      reason: '',
      value: 150,
      name: '优惠券名称',
      startAt: 1489104000,
      endAt: 1514592000,
      valueDesc: '1.5',
      unitDesc: '元',
    };

    const coupons = ref([coupon]);
    const showList = ref(false);
    const chosenCoupon = ref(-1);

    const onChange = (index:any) => {
      showList.value = false;
      chosenCoupon.value = index;
    };
    const onExchange = (code:any) => {
      coupons.value.push(coupon);
    };
    const onClickLeft = () => history.back();
</script>

<style lang="less" >

.van-nav-bar .van-icon{
    color: #333333;
}
.van-nav-bar__text{
    color: #333333;
}
</style>